using UnityEngine;

public class FizzyBubble : MonoBehaviour
{
	private FizzyBubblesController bubblesController;

	private SpriteRenderer spriteRenderer;

	public bool isVisible;

	private Vector3 maxPosition;

	private float speed;

	private void Awake()
	{
		speed = UnityEngine.Random.Range(3f, 5f);
		base.transform.localScale = Vector3.one * UnityEngine.Random.Range(0.7f, 1f);
		spriteRenderer = GetComponent<SpriteRenderer>();
	}

	private void Update()
	{
		if (isVisible)
		{
			Vector3 position = base.transform.position;
			if (position.y < maxPosition.y)
			{
				base.transform.position += Vector3.up * speed * Time.deltaTime;
				return;
			}
			isVisible = false;
			bubblesController.SendBubbleToGraveyard(base.transform);
			UnityEngine.Object.Destroy(this);
		}
	}

	public void SetMaxPosition(Vector3 maxPosition)
	{
		this.maxPosition = maxPosition;
	}

	public void SetBubblesControllerConnection(FizzyBubblesController controller)
	{
		bubblesController = controller;
	}

	public void SetSprite(Sprite sprite)
	{
		spriteRenderer.sprite = sprite;
	}
}
